#pipeline {
#    agent any
#
#    environment {
#        MAVEN_HOME = "/opt/maven"
#        PATH = "${MAVEN_HOME}/bin:${env.PATH}"
#        DOCKER_REGISTRY = 'http://registry:5000' // 替换为你的 Docker Registry URL
#        DOCKER_CREDENTIALS_ID = 'docker-registry-credentials' // 替换为你的凭证 ID
#        REPOSITORY = 'registry'
#    }
#
#    stages {
#        stage('Initialize') {
#                    steps {
#                        script {
#                            def date = new Date()
#                            def formattedDate = date.format("yyyy-MM-dd-HH-mm-ss", TimeZone.getTimeZone('UTC'))
#                            IMAGE_VERSION = formattedDate
#                            echo "Image version: ${IMAGE_VERSION}"
#                        }
#                    }
#                }
#
#        stage('Checkout') {
#                    steps {
#                        script {
#                            // 使用带有凭证的 Git URL
#                            checkout([$class: 'GitSCM', branches: [[name: '*/master']],
#                              doGenerateSubmoduleConfigurations: false,
#                              extensions: [],
#                              userRemoteConfigs: [[url: 'https://gitee.com/taigeerhugh/mall-plus.git',
#                                                  credentialsId: 'gitee-credentials']]])
#                        }
#                    }
#                }
#
#        stage('Build and Install All Modules') {
#            steps {
#                  sh 'mvn clean install'
#            }
#        }
#
#
#        stage('Build and Push mall-admin') {
#            steps {
#                dir('mall-admin') {
#                    sh 'mvn clean package'
#                    script {
#                        def image = docker.build("${REPOSITORY}/mall-admin:${IMAGE_VERSION}")
#                        docker.withRegistry("${DOCKER_REGISTRY}", "${DOCKER_CREDENTIALS_ID}") {
#                            image.push()
#                        }
#                    }
#                }
#            }
#        }
#
#        stage('Build and Push mall-auth') {
#            steps {
#                dir('mall-auth') {
#                    sh 'mvn clean package'
#                    script {
#                        def image = docker.build("${REPOSITORY}/mall-auth:${IMAGE_VERSION}")
#                        docker.withRegistry("${DOCKER_REGISTRY}", "${DOCKER_CREDENTIALS_ID}") {
#                            image.push()
#                        }
#                    }
#                }
#            }
#        }
#
#        stage('Build and Push mall-portal') {
#            steps {
#                dir('mall-portal') {
#                    sh 'mvn clean package'
#                    script {
#                        def image = docker.build("${REPOSITORY}/mall-portal:${IMAGE_VERSION}")
#                        docker.withRegistry("${DOCKER_REGISTRY}", "${DOCKER_CREDENTIALS_ID}") {
#                            image.push()
#                        }
#                    }
#                }
#            }
#        }
#
#        stage('Build and Push mall-gateway') {
#                    steps {
#                        dir('mall-gateway') {
#                            sh 'mvn clean package'
#                            script {
#                                def image = docker.build("${REPOSITORY}/mall-gateway:${IMAGE_VERSION}")
#                                docker.withRegistry("${DOCKER_REGISTRY}", "${DOCKER_CREDENTIALS_ID}") {
#                                    image.push()
#                                }
#                            }
#                        }
#                    }
#                }
#
#        stage('Build and Push mall-monitor') {
#                    steps {
#                        dir('mall-monitor') {
#                            sh 'mvn clean package'
#                            script {
#                                def image = docker.build("${REPOSITORY}/mall-monitor:${IMAGE_VERSION}")
#                                docker.withRegistry("${DOCKER_REGISTRY}", "${DOCKER_CREDENTIALS_ID}") {
#                                    image.push()
#                                }
#                            }
#                        }
#                    }
#                }
#
#        stage('Build and Push mall-search') {
#                    steps {
#                        dir('mall-search') {
#                            sh 'mvn clean package'
#                            script {
#                                def image = docker.build("${REPOSITORY}/mall-search:${IMAGE_VERSION}")
#                                docker.withRegistry("${DOCKER_REGISTRY}", "${DOCKER_CREDENTIALS_ID}") {
#                                    image.push()
#                                }
#                            }
#                        }
#                    }
#                }
#    }
#
#    post {
#        always {
#            cleanWs()
#        }
#    }
#}
